function post_ajax(url, data, suc_fun, err_fun) {
    $.ajax({
        url: url,
        method: 'POST',
        data: data,
        async: false,
        success: function (data) {
            suc_fun(data)

        },
        error: function () {
            err_fun()
        }
    })
}
function getSelectedText() {
    var url = '/modification/restaurant';
    var data = retrieve_data();
    if(localStorage.getItem('restaurant_1')=="") {
        alert("输入值为空")
    }
    else {
        var success = function () {
        };
        var error = function () {
            alert("失败");
        };
        post_ajax(url, data, success,error);


    }
}
function getText(){
    var url = '/modification/user';
    var data = return_data();
    if(localStorage.getItem('user_1')=="")
    {
        alert("输入值为空")
    }else {
        var success = function () {
        };
        var error = function () {
            alert("失败");
        };
        post_ajax(url, data, success, error);
    }
}
function getDisText(){
    var url = '/modification/dishes';
    var data = return_datd();
    if(localStorage.getItem('dis_1')==""||localStorage.getItem('pri_1')==""){
        alert("输入不完全")
    }
    else {
        var success = function () {
        };
        var error = function () {
            alert("失败");
        };
        post_ajax(url, data, success, error);
    }
    location.href="http://localhost:3000/modification/dishes?rest_name="+localStorage.getItem('rest_2')+""
}
function modifyDisText(){
    var url = '/modification/update';
    var data = return_datd();
    if(localStorage.getItem('dis_1')==""||localStorage.getItem('pri_1')==""){
        alert("输入不完全")
    }
    else {
        var success = function () {

        };
        var error = function () {
            alert("失败");
        };
        post_ajax(url, data, success, error);
    }
    location.href="http://localhost:3000/modification/dishes?rest_name="+localStorage.getItem('rest_2')+""
}
function modifyUser(){
    var url = '/modification/updateUser';
    var data = return_data();
    if(localStorage.getItem('user_1')=="")
    {
        alert("输入值为空")
    }else {
        var success = function () {
        };
        var error = function () {
            alert("失败");
        };
        post_ajax(url, data, success, error);
    }
}
function modifyRes(){
    var url = '/modification/updateRes';
    var data = retrieve_data();
    if(localStorage.getItem('restaurant_1')=="") {
        alert("输入值为空")

    }
    else {
        var success = function () {
        };
        var error = function () {
            alert("失败");
        };
        post_ajax(url, data, success,error);
    }
}
function return_datd(){
    var datd = {};
    datd['id']= localStorage.getItem('dishes_ID');
    datd['dis_name']= localStorage.getItem('dis_1');
    datd['rest_name']= localStorage.getItem('rest_2');
    datd['price']= localStorage.getItem('pri_1');
    console.log(datd);
    return datd
}
function return_data(){
    var datt = {};
    datt['user_name']= localStorage.getItem('user_1');
    datt['id']= localStorage.getItem('user_ID');
    return datt
}
function retrieve_data(){
    var date = {};
    date['res_name']= localStorage.getItem('restaurant_1');
    date['id']= localStorage.getItem('restID');
    console.log(date)
    return date
}